package codebot.elector;
import java.util.ArrayList;

/**
 * General class with methods that don't pertain to any of the entities but more
 * to the environment in which they act
 * 
 * @author Teo
 * 
 */

public final class Utils {

  public final static ISupporter getBestSupporter(ArrayList<?> al){
    int winner = -1, support = Integer.MIN_VALUE;
    for (int i = 0; i < al.size(); i++) {
      ISupporter c = (ISupporter) al.get(i);
      if (c.getSupport() > support) {
        support = c.getSupport();
        winner = i;
      }
    }
    return winner != -1 ? (ISupporter) al.get(winner) : null;
  }
}
